Socket
Socket
Sign inDemoInstall

style-selector

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

style-selector

CSS selector constructor.


Version published
Maintainers
1
Created
Source

style-selector Build Status Coverage Status

NPM

CSS selector constructor

Uses Slick to parse and tokenize the CSS selectors.

Install

Install with npm

npm install --save style-selector

Usage v2

var selector = require('style-selector'),
    bodySelector = selector('body', [ 0, 0, 0, 1 ]);

console.log(bodySelector);                  // { text: 'body', spec: [ 0, 0, 0, 1 ] }
console.log(bodySelector.parsed());         // { '0': { combinator: ' ', tag: 'body' }, length: 1 }
console.log(bodySelector.specificity());    // [ 0, 0, 0, 1 ]

Usage v1

var Selector = require('style-selector'),
    bodySelector = new Selector('body', [ 0, 0, 0, 1 ]);

console.log(bodySelector);                  // { text: 'body', spec: [ 0, 0, 0, 1 ] }
console.log(bodySelector.parsed());         // { '0': { combinator: ' ', tag: 'body' }, length: 1 }
console.log(bodySelector.specificity());    // [ 0, 0, 0, 1 ]

v2 API

selector(text, spec)

CSS selector constructor

text

Type: String
Default: none

Selector text

spec

Type: Array
Default: none

Optional, precalculated specificity

selector.parsed()

Get parsed selector

selector.specificity()

Lazy specificity getter

v1 API

Selector(text, spec)

CSS selector constructor

text

Type: String
Default: none

Selector text

spec

Type: Array
Default: none

Optional, precalculated specificity

Selector.prototype.parsed()

Get parsed selector

Selector.prototype.specificity()

Lazy specificity getter

Credit

The code for this module was originally taken from the Juice library.

License

MIT

Keywords

FAQs

Package last updated on 17 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc